package com.study.common.transaction;

import org.springframework.data.redis.core.RedisTemplate;

/**
 * @author yaojinshan
 * @version 1.0
 * @description: 积分的分布式事务类
 * @date 2019/5/31 14:36
 */
public class IntegeralDistributedTransaction extends AbstarctDistributedTransaction {
    private String userId; //用户标识
    private String integeralNum;//积分值
    //如果使用的是dubbo 服务 则传入对应的 facade
    //private RedPacketFacade redPacketFacade;
    //如果要使用redis服务 则需要传入redisTemplate
    private RedisTemplate redisTemplate;

    @Override
    public boolean execute() {
        //积分事务的正常业务
        return true;
    }

    @Override
    public boolean rollback() {
        //积分事务的回退业务

        return true;
    }


    public IntegeralDistributedTransaction() {

    }

    public IntegeralDistributedTransaction(String userId, String integeralNum, RedisTemplate redisTemplate) {
        this.userId = userId;
        this.integeralNum = integeralNum;
        this.redisTemplate = redisTemplate;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getIntegeralNum() {
        return integeralNum;
    }

    public void setIntegeralNum(String integeralNum) {
        this.integeralNum = integeralNum;
    }

    public RedisTemplate getRedisTemplate() {
        return redisTemplate;
    }

    public void setRedisTemplate(RedisTemplate redisTemplate) {
        this.redisTemplate = redisTemplate;
    }
}
